import Vue from 'vue'
import Router from 'vue-router'
import Layout from './components/Layout.vue'

Vue.use(Router);

const router = new Router({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes: [{
    path: '/',
    component: Layout,
    redirect: {
      name: 'child'
    },
    children: [
      // {
      //   path: '/home',
      //   name: 'home',
      //   component: () => import( /* webpackChunkName: "fail" */ '@/views/home/Home')
      // },
      {
        path: '/child',
        name: 'child',
        meta: {
          title: '报名管理'
        },
        component: () => import( /* webpackChunkName: "fail" */ '@/views/child/ChildList')
      },
       {
        path: '/lotteryWait',
        name: 'lotteryWait',
        meta: {
          title: '抽奖结果等待'
        },
        component: () => import( /* webpackChunkName: "fail" */ '@/views/lottery/LotteryWait')
      }
    ]
  },
  // {
  //   path: '/login',
  //   name: 'login',
  //   meta: {
  //     title: '登录'
  //   },
  //   component: () => import( /* webpackChunkName: "fail" */ '@/views/user/Login')
  // },
  {
    path: '/lottery',
    name: 'lottery',
    meta: {
      title: '摇号'
    },
    component: () => import( /* webpackChunkName: "fail" */ '@/views/lottery/Lottery')
  },
  {
    path: '/403',
    name: 'Exception403',
    meta: {
      title: '403'
    },
    component: () => import( /* webpackChunkName: "fail" */ '@/views/exception/403')
  },
  {
    path: '/404',
    name: 'Exception404',
    meta: {
      title: '404'
    },
    component: () => import( /* webpackChunkName: "fail" */ '@/views/exception/404')
  },
  {
    path: '/500',
    name: 'Exception500',
    meta: {
      title: '500'
    },
    component: () => import( /* webpackChunkName: "fail" */ '@/views/exception/500')
  },
  {
    path: '*',
    redirect: '/404',
    hidden: true
  }
  ]
})

router.beforeEach((to, from, next) => {
  next()
})

export default router;